home *** CD-ROM | disk | FTP | other *** search
/ Clickx 47 / Clickx 47.iso / assets / software / switchproxy.xpi / install.js next >
Encoding:
Text File  |  2006-11-27  |  2.1 KB  |  63 lines

  1.  
  2. const gName            = "Switch Proxies";
  3. const gAuthor        = "Jeremy Gillick";
  4. const gRegKey        = "/JeremyGillick/SwitchProxies";
  5. const gVersion        = "1.4.1";
  6. const gJar            = "switchproxy.jar";
  7.  
  8. var    error             = null;
  9. var oFolder            = getFolder("Current User", "chrome");
  10. var iContentFlag    = CONTENT | PROFILE_CHROME;
  11. var iLocaleFlag        = LOCALE | PROFILE_CHROME;
  12.  
  13. //Install in App or Profile?
  14. var existsInApplication = File.exists(getFolder(getFolder("chrome"), gJar));
  15. var existsInProfile     = File.exists(getFolder(oFolder, gJar));
  16. if(existsInApplication || (!existsInProfile && !confirm("Do you want to install the extension into your profile folder?\n(Cancel will install into the application folder)")))
  17. {
  18.     iContentFlag    = CONTENT | DELAYED_CHROME;
  19.     iLocaleFlag        = LOCALE | DELAYED_CHROME;
  20.     oFolder         = getFolder("chrome");
  21. }
  22.  
  23. //Uninstall Existing
  24. if(existsInApplication || existsInProfile)
  25.     uninstall(gRegKey);
  26.  
  27. //Init
  28. initInstall(gName, gRegKey, gVersion);
  29. setPackageFolder(oFolder);
  30. error = addFile(gAuthor, gVersion, "chrome/"+ gJar, oFolder, null);
  31.  
  32. //Register
  33. if(error == SUCCESS){
  34.  
  35.     registerChrome(iContentFlag, getFolder(oFolder, gJar), "content/");
  36.     registerChrome(iLocaleFlag, getFolder(oFolder, gJar), 'locale/cs-CZ/');
  37.     registerChrome(iLocaleFlag, getFolder(oFolder, gJar), 'locale/en-US/');
  38.     registerChrome(iLocaleFlag, getFolder(oFolder, gJar), 'locale/fr-FR/');
  39.     registerChrome(iLocaleFlag, getFolder(oFolder, gJar), 'locale/it-IT/');
  40.     registerChrome(iLocaleFlag, getFolder(oFolder, gJar), 'locale/is-IS/');
  41.     registerChrome(iLocaleFlag, getFolder(oFolder, gJar), 'locale/ja-JP/');
  42.     
  43.     error = performInstall(); //Install
  44.     
  45.     if(error != SUCCESS && error != 999){
  46.         switch(error){
  47.             case -215:
  48.                 alert("The installation of the extension failed.\nOne of the files being overwritten is read-only.");
  49.                 break;
  50.             case -235:
  51.                    alert("The installation of the extension failed.\nThere is insufficient disk space.");
  52.                 break;
  53.             default: 
  54.                 alert("The installation of the extension failed.\nThe error code is: " + error);
  55.         }
  56.         cancelInstall(error);
  57.     }
  58. }
  59. else{
  60.     alert("The installation failed.\n" + error);
  61.     cancelInstall(error);
  62. }
  63.